class Solution {
    public double averageWaitingTime(int[][] customers) {
        int SumTime = customers[0][0];
        double WaitTime = 0;
        for(int i = 0;i < customers.length;i ++){
            if(customers[i][0] > SumTime){
                WaitTime += customers[i][1];
                SumTime = customers[i][1] + customers[i][0];
            }else{
                SumTime += customers[i][1];
                WaitTime += SumTime - customers[i][0];
            }
        }
        return WaitTime / (customers.length);
    }
}